package com.f21.f21assessoria.converter;

import java.util.List;
import java.util.Set;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.FacesConverter;

import com.f21.f21assessoria.enums.DiasDaSemana;
import com.f21.f21assessoria.enums.EnumConverter;
import com.f21.f21assessoria.enums.Status;

@FacesConverter(value = "DiasSemanaConverter")
public class DiasSemanaConverter extends TemplateConverterEnum {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component,
			String value) {
		for (DiasDaSemana dia : DiasDaSemana.values()) {
			if (dia.getLabel().equalsIgnoreCase(value))
				return dia.getValue();
		}

		return null;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		String separador = "";
		StringBuffer stringBuffer = new StringBuffer();
		for( String dias : (List<String>) value){
			stringBuffer.append(separador);
			stringBuffer.append(dias);
			separador = ", ";
		}
		return stringBuffer.toString();
	}

}
